#!/bin/bash


# 下面是配置文件,请根据例子填写自己的配置信息

server_mail="test@nyoj.top"
mail_passwd="XXXXXXX"
mail_host="smtp.mxhichina.com"
mail_port=25
mail_username="nyoj测试账号"



# sendmail [用户邮箱] [标题] [内容]
sendmail()
{
	base64_mail=`echo -e "${server_mail}\c" | base64`
	base64_passwd=`echo -e "${mail_passwd}\c" | base64`
	to_mail=$1
	title=$2
	body=$3
	{
		sleep 1
		echo "EHLO ${server_mail}"
		sleep 0.1
		echo "AUTH LOGIN"
		sleep 0.1
		echo $base64_mail
		echo $base64_passwd
		sleep 0.1
		echo "MAIL FROM:<${server_mail}>"
		sleep 0.1
		echo "RCPT TO:<${to_mail}>"
		sleep 0.1
		echo "DATA"
		sleep 0.1
		echo "From:${mail_username}"
		echo "To:${to_mail}"
		echo "Subject:${title}"
		echo
		echo
		echo $body
		echo
		echo
		echo '.'
		sleep 1
		echo 'quit'
        sleep 1
	} | telnet $mail_host $mail_port
}

sendmail "1667629529@qq.com" "中文测试" "中文测试<html><a href=\"sda\"> sds</a><html>"
